package com.rec.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rec.entity.Teachers;
import com.rec.service.TeachersService;
@RestController
@RequestMapping("tea")
@CrossOrigin
public class TeachersController {
	
	@Autowired
	private TeachersService s;
	
	@RequestMapping("getAll")
	public Map<String,Object> getBySearch(String cardno,String name,String sex,
			Integer sectionid,Integer status,Integer page, Integer limit) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("cardno", cardno);
		params.put("name", name);
		params.put("sex", sex);
		params.put("sectionid", sectionid);
		params.put("status", status);
		limit = limit == null ? 10 : limit;
		page = page == null ? 0 : page - 1;
		params.put("limit", limit);
		params.put("page", page);
		System.out.println(s.all(params));
		return s.all(params);
	}
	
	@RequestMapping("add")
	public Integer add(Teachers Teachers){
		System.out.println(s.add(Teachers));
		return s.add(Teachers);
	}
	
	@RequestMapping("update")
	public Integer update(Teachers teachers){
		
		return s.update(teachers);
	}
	/**
	 * 单删
	 * @param id
	 * @return
	 * 
	 */
	@RequestMapping("delete")
	public Integer delete(Integer id){
		
		return s.delete(id);
	}
}
